Skip to main content

Java Interview Preparation Guide

1. Core Java Fundamentals

OOP Concepts ⭐⭐⭐

  • Encapsulation, Inheritance, Polymorphism, Abstraction
  • Method overloading vs overriding
  • Abstract classes vs Interfaces
  • Access modifiers (private, protected, public, default)
  • Static vs non-static members
  • Final keyword usage

Java Memory Management ⭐⭐⭐

  • Heap vs Stack memory
  • Garbage Collection (GC) types and algorithms
  • Memory leaks and prevention
  • String pool and intern() method
  • OutOfMemoryError scenarios

Exception Handling ⭐⭐⭐

  • Checked vs Unchecked exceptions
  • Try-catch-finally blocks
  • Custom exceptions
  • Exception propagation
  • Best practices for exception handling

2. Collections Framework ⭐⭐⭐

Must Know Collections

  • List: ArrayList, LinkedList, Vector
  • Set: HashSet, LinkedHashSet, TreeSet
  • Map: HashMap, LinkedHashMap, TreeMap, ConcurrentHashMap
  • Queue: PriorityQueue, ArrayDeque

Key Concepts

  • Time complexity of operations
  • When to use which collection
  • Difference between HashMap and HashTable
  • ConcurrentHashMap internal working
  • Comparable vs Comparator

3. Multithreading & Concurrency ⭐⭐⭐

Threading Basics

  • Thread creation (Runnable vs Thread)
  • Thread lifecycle and states
  • Synchronization (synchronized keyword)
  • Wait, notify, notifyAll methods
  • Deadlock, race conditions

Advanced Concurrency

  • ExecutorService and Thread pools
  • Callable and Future
  • CountDownLatch, CyclicBarrier, Semaphore
  • Atomic classes (AtomicInteger, AtomicReference)
  • Concurrent collections (ConcurrentHashMap, BlockingQueue)

4. Java 8+ Features ⭐⭐⭐

Lambda Expressions & Functional Interfaces

  • Syntax and usage
  • Built-in functional interfaces (Predicate, Function, Consumer, Supplier)
  • Method references

Stream API (Already covered in your code)

  • Intermediate vs Terminal operations
  • Parallel streams
  • Collectors class

Optional Class

  • Purpose and usage
  • Methods: isPresent(), ifPresent(), orElse(), orElseGet()

Other Java 8+ Features

  • Default and static methods in interfaces
  • Date Time API (LocalDate, LocalDateTime)
  • CompletableFuture

5. Spring Framework ⭐⭐⭐

Core Spring

  • Dependency Injection (DI) and Inversion of Control (IoC)
  • Bean lifecycle and scopes
  • ApplicationContext vs BeanFactory
  • Annotations: @Component, @Service, @Repository, @Controller

Spring Boot

  • Auto-configuration
  • Starters and dependencies
  • Application properties
  • Embedded servers

Spring MVC

  • DispatcherServlet
  • Controllers and RequestMapping
  • ModelAndView
  • REST APIs (@RestController, @RequestMapping, @GetMapping)

Spring Data JPA

  • Repository pattern
  • JPA annotations
  • Query methods
  • Custom queries

6. Database & JPA ⭐⭐

JDBC

  • Connection management
  • PreparedStatement vs Statement
  • Transaction management

JPA/Hibernate

  • Entity mapping (@Entity, @Table, @Id)
  • Relationships (@OneToMany, @ManyToOne, @ManyToMany)
  • Lazy vs Eager loading
  • N+1 problem and solutions
  • First and Second level cache

7. Design Patterns ⭐⭐

Must Know Patterns

  • Singleton (different implementations, thread safety)
  • Factory and Abstract Factory
  • Observer pattern
  • Strategy pattern
  • Decorator pattern
  • Builder pattern

Spring Specific Patterns

  • Dependency Injection
  • Template Method (JdbcTemplate, RestTemplate)
  • Proxy pattern (AOP)

8. System Design & Architecture ⭐⭐

Microservices

  • Microservices vs Monolithic architecture
  • Service discovery
  • API Gateway
  • Circuit breaker pattern

Caching

  • Types of caching (in-memory, distributed)
  • Redis, Ehcache
  • Cache eviction strategies

Message Queues

  • Apache Kafka, RabbitMQ
  • Publish-Subscribe pattern

9. Testing ⭐⭐

Unit Testing

  • JUnit 5 features
  • Mockito framework
  • Test doubles (mocks, stubs, spies)
  • @Mock, @MockBean annotations

Integration Testing

  • Spring Boot Test annotations
  • TestContainers
  • WebMvcTest, DataJpaTest

10. Performance & Optimization ⭐

JVM Tuning

  • Heap size configuration
  • GC tuning parameters
  • Monitoring tools (JVisualVM, JProfiler)

Code Optimization

  • String concatenation best practices
  • Collection choice impact
  • Database query optimization

11. Common Coding Problems ⭐⭐⭐

Data Structures & Algorithms

  • Arrays and String manipulation
  • LinkedList operations
  • Binary Trees (traversal, search)
  • Sorting and searching algorithms
  • HashMap internal working

Problem-Solving Patterns

  • Two pointers technique
  • Sliding window
  • Dynamic programming basics
  • Recursion and backtracking

12. Recent Java Features ⭐

Java 9-17 Features

  • Java 9: Modules, Stream API enhancements
  • Java 10: Local variable type inference (var)
  • Java 11: String methods, HTTP Client
  • Java 14: Switch expressions
  • Java 15: Text blocks
  • Java 17: Sealed classes, Pattern matching

13. Tools & Build Systems ⭐

Build Tools

  • Maven (pom.xml, dependencies, lifecycle)
  • Gradle basics

Version Control

  • Git commands and workflows
  • Branching strategies

IDEs

  • IntelliJ IDEA shortcuts and features
  • Debugging techniques

14. Web Technologies ⭐

REST APIs

  • HTTP methods and status codes
  • RESTful design principles
  • JSON processing (Jackson)

Security

  • Authentication vs Authorization
  • JWT tokens
  • Spring Security basics
  • HTTPS and SSL

Priority Learning Order:

High Priority (Focus 70% of time)

  1. Core Java + OOP
  2. Collections Framework
  3. Multithreading
  4. Stream API
  5. Spring Framework basics

Medium Priority (Focus 20% of time)

  1. JPA/Hibernate
  2. Design Patterns
  3. Testing (JUnit, Mockito)
  4. System Design basics

Low Priority (Focus 10% of time)

  1. Latest Java features
  2. Advanced Spring topics
  3. Performance tuning
  4. Build tools

Sample Interview Questions by Topic:

Core Java

  • "Explain the difference between == and equals()"
  • "What is the difference between String, StringBuilder, and StringBuffer?"
  • "How does HashMap work internally?"

Multithreading

  • "What is the difference between wait() and sleep()?"
  • "Explain deadlock and how to prevent it"
  • "What is the volatile keyword?"

Spring

  • "Explain dependency injection with examples"
  • "What is the difference between @Component and @Service?"
  • "How does Spring Boot auto-configuration work?"

System Design

  • "Design a URL shortener like bit.ly"
  • "How would you handle high traffic in a web application?"
  • "Explain caching strategies"

Practice Resources:

  1. Coding Practice: LeetCode, HackerRank
  2. Mock Interviews: Pramp, InterviewBit
  3. System Design: Grokking System Design, High Scalability blog
  4. Books: Effective Java, Java Concurrency in Practice
  5. Online Courses: Oracle Java certification courses

Final Tips:

  1. Practice coding on whiteboard/paper
  2. Explain your thought process clearly
  3. Ask clarifying questions
  4. Know time/space complexity
  5. Stay updated with latest Java features
  6. Build small projects to demonstrate skills